//线性图初始化
function linear(domId, title, subtitle, xAxis, yAxis, tooltip, series, enableprint) {
    $('#' + domId).highcharts({
        title: {
            text: title,
            x: -20 //center
        },
        credits: {
            enabled: false
        },
        subtitle: {
            text: subtitle,
            x: -20
        },
        xAxis: {
            categories: xAxis
        },
        yAxis: {
            title: {
                text: yAxis
            },
            min: 0,
            plotLines: [{
                value: 0,
                width: 1,
                color: '#000000'
            }]
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + ': ' + Highcharts.numberFormat(this.y, 2, '.') + tooltip + '<b>';
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
        series: series,
        lang: {
            noData: '暂无数据'
        },
        noData: {
            style: {
                fontSize: '20px',
                color: '#303030'
            }
        },
        exporting: {
            enabled: enableprint
        }
    });

}

//时间不连续的线形图
function linear_date(domId, title, subtitle, xAxis, yAxis, tooltip, series) {
    $('#' + domId).highcharts({
        chart: {
            type: 'spline'
        },
        credits: {
            enabled: false
        },
        title: {
            text: title
        },
        subtitle: {
            text: subtitle
        },
        xAxis: {
            type: 'datetime',
            dateTimeLabelFormats: { // don't display the dummy year
                minute: '%H:%M'
            }
        },
        yAxis: {
            title: {
                text: '正常工作'
            },
            categories: [0, 1]
            //,
            //min: 0
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + '</b><br/>' +
                    Highcharts.dateFormat('%H:%M', this.x);
            }
        },
        series: series
        ,
        lang: {
            noData: '未亮灯'
        },
        noData: {
            style: {
                fontSize: '20px',
                color: '#303030'
            }
        }
    })
}
//饼状图初始化方法
function pie(domId, title, subtitle, seriesname, series, enableprint) {
    $('#' + domId).highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        credits: {
            enabled: false
        },
        title: {
            text: title
        },
        subtitle: {
            text: subtitle,
            x: -20
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                }
            }
        },
        series: [{
            type: 'pie',
            name: seriesname,
            data: series
        }],
        lang: {
            noData: '暂无数据'
        },
        noData: {
            style: {
                fontSize: '20px',
                color: '#303030'
            }
        },
        exporting: {
            enabled: enableprint
        }
    });
}

//条形图初始化方法drilldown
function bar(domId, title, subtitle, xAxis, yAxis, series, unit) {
    $('#' + domId).highcharts({
        chart: {
            type: 'column'
        },
        credits: {
            enabled: false
        },
        title: {
            text: title
        },
        subtitle: {
            text: subtitle
        },
        xAxis: {
            categories: xAxis
        },
        yAxis: {
            min: 0,
            title: {
                text: yAxis
            }
        },
        tooltip: {
            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
            '<td style="padding:0"><b>{point.y} ' + unit + '</b></td></tr>',
            footerFormat: '</table>',
            shared: true,
            useHTML: true
        },
        plotOptions: {
            column: {
                pointPadding: 0.2,
                borderWidth: 0
            }
        },
        series: series,
        lang: {
            noData: '暂无数据'
        },
        noData: {
            style: {
                fontSize: '20px',
                color: '#303030'
            }
        }
    });
}


//条形图初始化方法
function detailbar(domId, title, subtitle, xAxis, yAxis, series, unit) {
    $('#' + domId).highcharts({
        chart: {
            type: 'column'
        },
        credits: {
            enabled: false
        },
        title: {
            text: title
        },
        subtitle: {
            text: subtitle
        },
        xAxis: {
            categories: xAxis
        },
        yAxis: {
            min: 0,
            title: {
                text: yAxis
            }
        },
        legend: {
            align: 'right',
            x: -70,
            verticalAlign: 'top',
            y: 20,
            floating: true,
            backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
            borderColor: '#CCC',
            borderWidth: 1,
            shadow: false
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.x + '</b><br/>' +
                    this.series.name + ': ' + this.y + '<br/>' +
                    '总耗能: ' + this.point.stackTotal;
            }
        },
        plotOptions: {
            column: {
                stacking: 'normal',
                dataLabels: {
                    enabled: true,
                    color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'black'
                }
            }
        },
        series: series,
        colors: ['#3599EE', '#27B3C3'],
        lang: {
            noData: '暂无数据'
        },
        noData: {
            style: {
                fontSize: '20px',
                color: '#303030'
            }
        }
    });
}